package com.zq.im;

import android.content.Intent;
import android.os.CountDownTimer;

import com.gyf.immersionbar.ImmersionBar;
import com.zq.im.utils.SharePreferenceUtils;

public class SplashActivity extends BaseActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initData() {
        super.initData();
        countDown();
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this)
                .statusBarDarkFont(true)
                .statusBarColor(R.color.white)
                .init();
    }


    void countDown() {
        //三秒 计入主界面
        new CountDownTimer(1000, 1000) {

            @Override
            public void onTick(long millisUntilFinished) {
            }

            @Override
            public void onFinish() {
                String token = SharePreferenceUtils.getString("token");
                if (token.length() > 200) {
                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                    intent.putExtra("action", "login");
                    startActivity(intent);
                    finish();
                }

            }
        }.start();

    }


}